package com.sky.controller.user;

import com.sky.entity.Setmeal;
import com.sky.result.Result;
import com.sky.service.UserSetmealService;
import com.sky.vo.DishItemVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user/setmeal")
@Slf4j
@Api(tags = "套餐相关接口")
public class UserSetmealController {
    @Autowired
    private UserSetmealService userSetmealService;

@GetMapping("/list")
@ApiOperation(value = "根据分类id查询包含的套餐")
@Cacheable(value = "userSetmeal",key="#categoryId")
     public  Result<List<Setmeal>> findMeal(Integer categoryId){

    log.info("用户套餐查询的信息为，{}",categoryId);
    List<Setmeal> userSetmealServiceByid = userSetmealService.findByid(categoryId);
    return Result.success(userSetmealServiceByid);
}

    @GetMapping("/dish/{id}")
    @ApiOperation(value = "根据套餐id查询菜品")
    public  Result<List<DishItemVO>> findMeal(@PathVariable Long id){
        log.info("根据套餐id查询的信息为，{}",id);
        List<DishItemVO> dish = userSetmealService.findDish(id);
        return Result.success(dish);
    }


}
